//
//  HSClassRoomTableViewCell.swift
//  HomeSchoolDemo
//
//  Created by rimi on 16/10/10.
//  Copyright © 2016年 黄华强. All rights reserved.
//

import UIKit

class HSClassRoomTableViewCell: UITableViewCell {
    
    
    var testTitle:UILabel!
    var teachNameLabel:UILabel!
    var subjectsButton:UIButton!
    var timeLabel:UILabel!
    var iconImageView:UIImageView!
    
    var model:HSClassRoomModel? {
        didSet{
            
            testTitle.text = model?.picgroupname
            teachNameLabel.text = model?.createName
            subjectsButton.setTitle(model?.course, for: .normal)
            timeLabel.text = model?.creattime
            
            if model?.usersex == "男" {
                iconImageView.image = UIImage(named: "tboy")
            } else {
                iconImageView.image = UIImage(named: "tgril")
            }
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        testTitle = UILabel(frame: CGRect(x: 12 + screenW * 0.2, y: 8, width: 100, height: 20))
        testTitle.text = "作业标题"
        testTitle.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.04)
        contentView.addSubview(testTitle)
        
        teachNameLabel = UILabel(frame: CGRect(x: UIScreen.main.bounds.width * 0.7, y: 8, width: UIScreen.main.bounds.width * 0.25, height: 20))
        teachNameLabel.text = "王老师"
        teachNameLabel.textAlignment = NSTextAlignment.right
        teachNameLabel.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.035)
        contentView.addSubview(teachNameLabel)
        
        subjectsButton = UIButton(frame: CGRect(x: 12 + screenW * 0.2, y: 36, width: 36, height: 16))
        subjectsButton.layer.cornerRadius = 8
        subjectsButton.setTitle("数学", for: .normal)
        subjectsButton.setTitleColor(#colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1), for: .normal)
        subjectsButton.titleLabel?.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.03)
        subjectsButton.isUserInteractionEnabled = false
        subjectsButton.layer.borderColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1).cgColor
        subjectsButton.layer.borderWidth = 1
        contentView.addSubview(subjectsButton)
        
        timeLabel = UILabel(frame: CGRect(x: UIScreen.main.bounds.width * 0.4, y: 40, width: UIScreen.main.bounds.width * 0.55, height: 20))
        timeLabel.textAlignment = NSTextAlignment.right
        timeLabel.textColor = #colorLiteral(red: 0.6980392157, green: 0.6980392157, blue: 0.6980392157, alpha: 1)
        timeLabel.text = "2016-10-10 08:08"
        timeLabel.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.03)
        contentView.addSubview(timeLabel)
        
        iconImageView = UIImageView(frame: CGRect(origin: CGPoint(x: 16, y: 9), size: CGSize(width: 50, height: 50)))
        iconImageView.layer.cornerRadius = 25
        iconImageView.layer.masksToBounds = true
        iconImageView.image = UIImage(named: "tboy")
        contentView.addSubview(iconImageView)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
